//package com.sx.manage.service.operation;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//
//import javax.annotation.Resource;
//
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
//
//import com.sx.common.util.DateUtil;
//import com.sx.common.util.http.HttpPoolManager;
//import com.sx.common.util.http.model.HttpResult;
//import com.sx.common.util.json.JackJsonUtil;
//import com.sx.common.util.type.ContentType;
//import com.sx.manage.biz.consumer.info.IMNetworkPersonConsumerBiz;
//import com.sx.manage.service.consumer.MConsumerWebServiceImpl;
//import com.sx.manage.service.consumer.info.IMConsumerOperationInfoService;
//import com.sx.manage.util.WebServiceUtil;
//import com.sx.manage.util.WebServiceUtils;
//import com.sx.model.manage.mybatis.vo.result.ResultListVO;
//import com.sx.model.manage.mybatis.vo.result.ResultValueVO;
//import com.sx.model.manage.mybatis.web.form.huaxia2.PayCodeNoForm;
//import com.sx.model.manage.mybatis.web.form.huaxia2.TradeDetailForm;
//import com.sx.model.manage.mybatis.web.vo.huaxia02.B2BElectronicReceiptUrlVO;
//import com.sx.model.manage.mybatis.web.vo.huaxia02.B2BTradeDetailCycleVO;
//import com.sx.model.manage.mybatis.web.vo.huaxia02.B2BTradeDetailResultVO;
///**
// * 交易详情查询
// * @author zwm
// *
// */
//@Service("tradeDetailWebService")
//public class TradeDetailWebService {
//	
//	private Logger log = LoggerFactory.getLogger(this.getClass());
//	// 扩展信息
//	@Resource(name = "consumerOperationInfoServiceImpl")
//	private IMConsumerOperationInfoService consumerOperationInfoServiceImpl;
//	// 用户信息新接口
//	@Resource(name = "mNetworkPersonConsumerBizImpl")
//	public IMNetworkPersonConsumerBiz mNetworkPersonConsumerBizImpl;
//	
//	@Resource(name="webServiceUtils")
//	private WebServiceUtils webServiceUtils;
//	
//	@Resource(name = "httppoolmanager")
//	private HttpPoolManager httpPoolManager;
//	
//	/** **/
//	@SuppressWarnings("rawtypes")
//	public ResultValueVO printing_electronic_return(String transCodeId) {
//		if(StringUtils.isBlank(transCodeId)) {
//			log.info("打印电子回执单失败，交易流水号为空transCodeId={}",transCodeId);
//			return new ResultValueVO("m.parameter.is.null");
//		}
//		ResultValueVO valueVO = new ResultValueVO<>();
////		PayCodeNoForm codeForm = new PayCodeNoForm();
////		codeForm.setPay_code_no(transCodeId);
////		try {
////			log.info("查询用户交易详情consumer_id={}",transCodeId);
////			HttpResult httpResult = httpPoolManager.getHttpClient().postAuthorization(WebServiceUtil.getPayCodeNo(), ContentType.JSON, null, MConsumerWebServiceImpl.HTTP_TIME_OUT, JackJsonUtil.objToJson(codeForm), "UTF-8");
////			if (null != httpResult && 200 == httpResult.getStatus()) {
////				log.info("账户签约信息查询 httpResult={}", httpResult.getHttpresult());
////				B2BElectronicReceiptUrlVO urlVO = JackJsonUtil.jsonToJavaBean(httpResult.getHttpresult(), B2BElectronicReceiptUrlVO.class);
////				valueVO.setValue_(urlVO.getElectronicReceiptUrl());
////			}
////		}catch(Exception e) {
////			log.error("查询用户交易详情consumer_id={},e={}",transCodeId,e);
////			valueVO.setSuccess(false);
////			valueVO.setMsg("查询失败");
////		}
//		return valueVO;
//	}
//	
//	/**
//	 * 交易详情查询
//	 * @return
//	 */
//	public ResultListVO<B2BTradeDetailCycleVO> findTradeDetail(Long consumer_id,TradeDetailForm form){
//		
//		if(StringUtils.isBlank(form.getStartTimes())||StringUtils.isBlank(form.getEndTimes())) {
//			log.info("请选择时间段，间隔不能超过三个月 form={}",form);
//			return new ResultListVO<>(false,null,"请选择时间段，间隔不能超过三个月");
//		}
//		if(null!=consumer_id) {
//			form.setTradeMemCode(webServiceUtils.queryTradeMemberCode(consumer_id));
//			form.setSubAccount(webServiceUtils.queryBranchAccountNo(consumer_id));
//		}else{
//			if(StringUtils.isNotBlank(form.getSubAccount())
//					&&StringUtils.isBlank(form.getTradeMemCode())) {
//				form.setTradeMemCode(webServiceUtils.queryTradeMemberCode(webServiceUtils.queryConsumerIdByBankAccountNo(form.getSubAccount())));
//			}
//			if(StringUtils.isNotBlank(form.getTradeMemCode())
//					&&StringUtils.isBlank(form.getSubAccount())) {
//				form.setSubAccount(webServiceUtils.queryBranchAccountNo(webServiceUtils.queryConsumerIdByTradeMemCode(form.getTradeMemCode())));
//			}
//		}
//		if(StringUtils.isBlank(form.getTradeMemCode())){
//			log.info("没有交易会员代码返回为空数据consumer_id={},form={}",consumer_id,form);
//			return new ResultListVO<>();
//		}
//		
//		form.setStartTimes(DateUtil.stringToTimeFormat(form.getStartTimes(),"yyyy-MM-dd HH:mm", "yyyyMMddHHmm"));
//		form.setEndTimes(DateUtil.stringToTimeFormat(form.getEndTimes(),"yyyy-MM-dd HH:mm", "yyyyMMddHHmm"));
//		form.setDate("");
//		form.setPayCode("");
//		if(StringUtils.isBlank(form.getOtherSubAccount())) {
//			form.setOtherSubAccount("");
//		}
//		try {
//			log.info("查询用户交易详情consumer_id={},form={}",consumer_id,form);
//			HttpResult httpResult = httpPoolManager.getHttpClient().postAuthorization(WebServiceUtil.getTardeAdaptertTradeDetailUrl(), ContentType.JSON, null, MConsumerWebServiceImpl.HTTP_TIME_OUT, JackJsonUtil.objToJson(form), "UTF-8");
//			if (null != httpResult && 200 == httpResult.getStatus()) {
//				log.info("账户签约信息查询 httpResult={}", httpResult.getHttpresult());
//				B2BTradeDetailResultVO statusVO = JackJsonUtil.jsonToJavaBean(httpResult.getHttpresult(), B2BTradeDetailResultVO.class);
//				if (!statusVO.isSuccess()) {
//					return new ResultListVO<>(false,null,"查询交易详情失败");
//				}
//				ResultListVO<B2BTradeDetailCycleVO> result = new ResultListVO<>();
//				if(null!=statusVO.getCycle()){
//					for(B2BTradeDetailCycleVO cycleVO:statusVO.getCycle()){
//						if("1".equals(cycleVO.getPayPayeeSign())){
//							cycleVO.setPayPayeeSign("收款");
//						}else if("0".equals(cycleVO.getPayPayeeSign())){
//							cycleVO.setPayPayeeSign("付款");
//						}
//						if(StringUtils.isNotBlank(cycleVO.getTradeTimes())) {
//							cycleVO.setTradeTimes(DateUtil.stringToTimeFormat(cycleVO.getTradeTimes(),"yyyyMMddHHmmss",DateUtil.TIMESTAMP_FORMAT));
//						}
//						cycleVO.setCreMoney(moneyHandle(cycleVO.getCreMoney()));
//						cycleVO.setSubAccountMoney(moneyHandle(cycleVO.getSubAccountMoney()));
//					}
//					result.setData(statusVO.getCycle());
//					result.setRecordsFiltered(Long.valueOf(statusVO.getCount()));
//					result.setRecordsTotal(Long.valueOf(statusVO.getCount()));
//				}
//				return result;
//			}
//		}catch(Exception e) {
//			log.error("查询用户交易详情异常consumer_id={},form={},error={}",consumer_id,form,e);
//		}
//		return new ResultListVO<>(false,null,"查询交易详情失败");
//	}
//	/**
//	 * 交易详情查询
//	 * @return
//	 */
//	public ResultListVO<B2BTradeDetailCycleVO> findTradeDetailCompany(Long companyId,TradeDetailForm form){
//		
//		if(StringUtils.isBlank(form.getStartTimes())||StringUtils.isBlank(form.getEndTimes())) {
//			log.info("请选择时间段，间隔不能超过三个月 form={}",form);
//			return new ResultListVO<>(false,null,"请选择时间段，间隔不能超过三个月");
//		}
//		if(null!=companyId) {
//			form.setSubAccount(webServiceUtils.queryBranchAccountNoCompany(companyId));
//			form.setTradeMemCode(webServiceUtils.queryTradeMemberCodeCompany(companyId));	
//		}else{
//			if(StringUtils.isNotBlank(form.getSubAccount())
//					&&StringUtils.isBlank(form.getTradeMemCode())) {
//				form.setTradeMemCode(webServiceUtils.queryTradeMemberCodeCompany(webServiceUtils.queryCompanyIdByBankAccountNo(form.getSubAccount())));
//			}
//			if(StringUtils.isNotBlank(form.getTradeMemCode())
//					&&StringUtils.isBlank(form.getSubAccount())) {
//				form.setSubAccount(webServiceUtils.queryBranchAccountNoCompany(webServiceUtils.queryCompanyIdByTradeMemCode(form.getTradeMemCode())));
//			}
//		}
//		if(StringUtils.isBlank(form.getTradeMemCode())){
//			log.info("没有交易会员代码返回为空数据companyId={},form={}",companyId,form);
//			return new ResultListVO<>();
//		}
//		form.setStartTimes(DateUtil.stringToTimeFormat(form.getStartTimes(),"yyyy-MM-dd HH:mm", "yyyyMMddHHmm"));
//		form.setEndTimes(DateUtil.stringToTimeFormat(form.getEndTimes(),"yyyy-MM-dd HH:mm", "yyyyMMddHHmm"));
//		form.setDate("");
//		form.setPayCode("");
//		if(StringUtils.isBlank(form.getOtherSubAccount())) {
//			form.setOtherSubAccount("");
//		}
//		
//		try {
//			log.info("查询用户交易详情companyId={},form={}",companyId,form);
//			HttpResult httpResult = httpPoolManager.getHttpClient().postAuthorization(WebServiceUtil.getTardeAdaptertTradeDetailUrl(), ContentType.JSON, null, MConsumerWebServiceImpl.HTTP_TIME_OUT, JackJsonUtil.objToJson(form), "UTF-8");
//			if (null != httpResult && 200 == httpResult.getStatus()) {
//				log.info("账户签约信息查询 httpResult={}", httpResult.getHttpresult());
//				B2BTradeDetailResultVO statusVO = JackJsonUtil.jsonToJavaBean(httpResult.getHttpresult(), B2BTradeDetailResultVO.class);
//				if (!statusVO.isSuccess()) {
//					return new ResultListVO<>(false,null,"查询交易详情失败");
//				}
//				ResultListVO<B2BTradeDetailCycleVO> result = new ResultListVO<>();
//				if(null!=statusVO.getCycle()){
//					for(B2BTradeDetailCycleVO cycleVO:statusVO.getCycle()){
//						if("1".equals(cycleVO.getPayPayeeSign())){
//							cycleVO.setPayPayeeSign("收款");
//						}else if("0".equals(cycleVO.getPayPayeeSign())){
//							cycleVO.setPayPayeeSign("付款");
//						}
//						if(StringUtils.isNotBlank(cycleVO.getTradeTimes())) {
//							cycleVO.setTradeTimes(DateUtil.stringToTimeFormat(cycleVO.getTradeTimes(),"yyyyMMddHHmmss",DateUtil.TIMESTAMP_FORMAT));
//						}
//						cycleVO.setCreMoney(moneyHandle(cycleVO.getCreMoney()));
//						cycleVO.setSubAccountMoney(moneyHandle(cycleVO.getSubAccountMoney()));
//					}
//					result.setData(statusVO.getCycle());
//					result.setRecordsFiltered(Long.valueOf(statusVO.getCount()));
//					result.setRecordsTotal(Long.valueOf(statusVO.getCount()));
//				}
//				return result;
//			}
//		}catch(Exception e) {
//			log.error("查询用户交易详情异常companyId={},form={},error={}",companyId,form,e);
//		}
//		return new ResultListVO<>(false,null,"查询交易详情失败");
//	}
//	
//	public String moneyHandle(String money){
//		if(StringUtils.isBlank(money)) {
//			return money;
//		}
//		BigDecimal moenyBig = new BigDecimal(money);
//		BigDecimal resultMoney= moenyBig.divide(new BigDecimal("100"),2, RoundingMode.HALF_UP);
//		return resultMoney.toString();
//	}
//	
//	public static void main(String[] args) {
//		BigDecimal moenyBig = new BigDecimal("2000");
//		BigDecimal resultMoney= moenyBig.divide(new BigDecimal("100"),2, RoundingMode.HALF_UP);
//		//moenyBig.divide(resultMoney, 2, RoundingMode.HALF_UP);
//		System.out.println(resultMoney.toString());
//	}
//}
